import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as goodActions from '../../actions/good'
import * as shoppingCartActions from '../../actions/shoppingCart'

export function connectProduct(Component) {
	class WrapComp extends React.Component {
		render() {
			return (
				<div><Component {...this.props} /></div>
			);
		}
	}
	 const mapStateToProps = (state) => ({
   		good: {
   			goodData: state.good.goodData,
   			isFetched: state.good.isFetched
   		},
   		cart: {
   			isAdded: state.shoppingCart.isAdded,
   		}
  	});
  	const mapDispatchToProps = (dispatch) => ({
		goodActions: bindActionCreators(goodActions, dispatch),
		shoppingCartActions: bindActionCreators(shoppingCartActions, dispatch)
  	});
	return connect(mapStateToProps, mapDispatchToProps)(WrapComp);
}